package com.java.base.exercise.current;

import com.java.base.exercise.current.entity.BoilWater;
import com.java.base.exercise.current.entity.Promise;
import com.java.base.exercise.current.entity.TeaAndCup;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author RenPu
 * @Date 2022/1/8 16:29
 * @Version 1.0
 * @Description:
 **/
public class Test006 {


    public static void main(String[] args) throws Exception {


        long startTime = System.currentTimeMillis();

//        Thread thread = new Thread(() -> {
//            try{
//                Thread.sleep(15000);
//                BoilWater boilWater = new BoilWater();
//                boilWater.setStatus(true);
//            } catch (Exception e){
//                e.printStackTrace();
//            }
//            System.out.println("任务-结束.....接下来执行任二...22222222....");
//        },"任务一（烧水任务）:总消费时间需要15分钟.................");
//            thread.start();
//            thread.join();


        FutureTask de=new FutureTask<Object>(new Callable<Object>() {


            @Override
            public Object call() throws Exception {
                return null;
            }
        });









        Promise promise = new Promise();
        FutureTask<Object> objectFutureTask = promise.create(startTime);


        System.out.println("任务二开始：准备茶叶，茶杯，需要3分钟");
        TeaAndCup teaAndCup = new TeaAndCup();
        Thread.sleep(3000);
        teaAndCup.setStatus(true);
        System.out.println("任务二结束...11111111..任务全部完成.......");

        if(!objectFutureTask.isDone()){
            System.out.println("水还没有烧好，请稍等一会........");

        }
        BoilWater boilWater = (BoilWater)objectFutureTask.get();

        System.out.println("总共耗时："+(System.currentTimeMillis()-startTime)+"ms");




    }

}
